/**
 * 通用数据
 */
export default class biz {
    constructor() { }

    // 默认table分页
    static pages = [20, 50, 100];
    static dftPageSize = 20;

    static calcPageSize(size) {
        if (this.pages.indexOf(size) > -1) {
            return size;
        } else {
            return this.dftPageSize;
        }
    }

    // 状态框class




    // 所有的状态
    static ALL_STATUS = {
        ZC: "暂存",
        DHC: "待核查",
        JA_BSH: "结案(核查不属实)",
        DHCTG: "待核查通过",
        HCTGBH: "核查通过驳回",
        DLA: "待立案",
        JA_BLA: "结案(不立案)",
        DLATG: "待立案通过",
        JLTGBH: "立案通过驳回",
        XZDC: "协助调查",
        RHJC: "入户检查",
        SFPH: "是否配合",
        XCKC: "现场勘查",
        DCBG: "调查报告",
        XZCFGZS: '行政处罚告知书',
        FZSH: '法制审核',
        XZCFJDS: "行政处罚决定书",
        DJA: "待结案",
        JA_ZC: '结案(正常)',

    };

    // 特殊状态名称
    static SPECIAL_STATUS = {
        // 测试方案列表状态
        testPlanStatus: {
            DONE: "已启用",
        },
        fileLibrary: {
            DONE: "已生效",
        },
        reviewStatus: {
            ENDED: "已結束",
        },
        gdglStatus: {
            DONE: "已生效",
        },
    };
    static statusEnum = {
        ts: [
            {
                ZC: "暂存",
                DHC: "待核查",
                JA_BSH: "结案(核查不属实)",
                DHCTG: "待核查通过",
                HCTGBH: "核查通过驳回",
                DLA: "待立案",
                JA_BLA: "结案(不立案)",
                DLATG: "待立案通过",
                JLTGBH: "立案通过驳回",
                XZDC: "协助调查",
                RHJC: "入户检查",
                SFPH: "是否配合",
                XCKC: "现场勘查",
                DCBG: "调查报告",
                XZCFGZS: '行政处罚告知书',
                FZSH: '法制审核',
                XZCFJDS: "行政处罚决定书",
                DJA: "待结案",
                JA_ZC: '结案(正常)',
            }
        ],

    };

    static getStatusName(key, status) {
        if (this.SPECIAL_STATUS[key]) {
            let name = this.SPECIAL_STATUS[key][status];
            if (name) {
                return name;
            }
        }
        return this.ALL_STATUS[status];
    }

    static getStatusMap(key) {
        let obj = {};
        let arr = this.statusEnum[key];
        if (!arr) {
            return {};
        }
        for (let k of arr) {
            obj[k] = this.getStatusName(key, k);
        }
        return obj;
    }

    static getStatusOption(key) {
        let options = [];
        let arr = this.statusEnum[key];
        if (!arr) {
            return [];
        }
        for (let k of arr) {
            options.push({
                label: this.getStatusName(key, k),
                value: k,
            });
        }
        return options;
    }

    static MESSAGE_ENUM = {

    };
    static fileSizeName(bytes) {
        var sizes = ["Bytes", "KB", "MB", "GB", "TB"];
        // eslint-disable-next-line eqeqeq
        if (bytes == 0) return "0 Byte";
        // @ts-ignore
        var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
        // @ts-ignore
        return Math.round(bytes / Math.pow(1024, i), 2) + " " + sizes[i];
    }
    static setFileSize(size) {
        if (size === 1) {
            // return
        }
    }
}
